<?php

/* This feed expects one parameter posted as a POST parameter:
 * Name:testcaseId / Type:integer. / The index of the test case(function) to execute.
 */
require_once(dirname(__FILE__) . "/databaseTesterTemplateData.php");
require_once(dirname(__FILE__) . "/../../commons/common-funcs.php");
require_once(dirname(__FILE__) . "/databaseTestCases.php");

session_start();

$testcaseId = (int) $_POST['testcaseId'];
$testcaseParam1 = $_POST['testcaseParam1'];
$testcaseParam2 = $_POST['testcaseParam2'];
$testcaseParam3 = $_POST['testcaseParam3'];

setcookie('selectedTestcaseId', $testcaseId);


$functionName = $arFunctions[(int) $testcaseId];
$testResult = "Problem";

//cf the databaseTesterTemplateData.php for correspondance between index and the function
switch ($testcaseId) {
    case '1':
        //insertIntoTable
        connect();
        $testResult = testInsertIntoTable();


        break;
    case '2':
        connect();
        $testResult = testDbCreateWebPage($testcaseParam1, $testcaseParam2);
        break;
    case '3':
        connect();
        $testResult = testDbCreateTag($testcaseParam1);
        break;
    case '4':
        connect();
        $testResult = testDbCreateWebpageHasTags($testcaseParam1,$testcaseParam2);
        break;
    default:
        echo buildHtmlPresentationForError(__FILE__, __FUNCTION__, " The test case for function $functionName is not handled yet...");
        exit();
}


echo json_encode($testResult);
?>
